/*
{
    color:'#fff',
    lineWidth:10,
    pos:[
        {x:10,y:20},
        {x:15,y:20}
    ]
}
*/
//将本地坐标缩放成标准的375*320下的坐标，上传至服务器
function localToServer(posArr){
    const scale=ServerCanvasWidth/document.body.clientWidth;
    return scalePosArr(posArr,scale)
}

//将服务器标准的375*320下的坐标转化成本地canvas下的坐标
function serverToLocal(posArr){
    const scale=document.body.clientWidth/ServerCanvasWidth;
    return scalePosArr(posArr,scale)
}

function scalePosArr(posArr,scale){
    return posArr.map(pos=>{
        return {
            x:pos.x*scale,
            y:pos.y*scale
        }
    })
}

const ServerCanvasWidth=375;

export default {
    ServerCanvasWidth,
    localToServer,
    serverToLocal,
    scalePosArr
}